package zookeep;

import org.apache.zookeeper.AsyncCallback;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

/**
 * @author yinchengfeng
 * @date 2022/3/9
 * @Description:
 */
public class MyWatchCallBack implements Watcher,AsyncCallback.StatCallback, AsyncCallback.DataCallback {
    ZooKeeper zkClient;
    String appPath;
    public MyWatchCallBack(ZooKeeper zkClient, String appPath) {
        this.zkClient = zkClient;
        this.appPath = appPath;
    }

    @Override
    public void processResult(int rc, String path, Object ctx, byte[] data, Stat stat) {

    }

    @Override
    public void processResult(int rc, String path, Object ctx, Stat stat) {
        if(stat!=null){
            zkClient.getData(appPath,this,this,"MyWatchCallBack");
        }
    }

    @Override
    public void process(WatchedEvent event) {

    }
}
